package cn.kduck.webapp.security;

import cn.kduck.module.account.service.RetrieveCaptchaSender;
import cn.kduck.module.message.service.SmsMessageSender;
import cn.kduck.module.message.service.sender.SenderParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MyRetrieveCaptchaSender implements RetrieveCaptchaSender {

    @Autowired
    private SmsMessageSender messageSender;

    @Override
    public void sendCaptcha(String captcha, String target) {
        SenderParam param = new SenderParam();
        param.setParams(new String[]{"code:"+captcha});
        param.setPhoneNum(target);
//      param.setTemplateCode("1435347");//腾讯
        param.setTemplateCode("SMS_187750044");//阿里云
        messageSender.sendMessage(param);
    }
}
